package com.awesome.ipcdemo.contentprovider;

import androidx.appcompat.app.AppCompatActivity;

import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;

import com.awesome.ipcdemo.R;
import com.awesome.ipcdemo.aidl.bean.Game;
import com.awesome.sdk.util.ShowLogUtil;

public class ContentProviderActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_content_provider);
        Uri uri = Uri.parse("content://com.example.liuwangshu.mooncontentprovider.GameProvider");
        ContentValues mContentValues = new ContentValues();
        mContentValues.put("_id",2);
        mContentValues.put("name","大航海时o1");
        mContentValues.put("describe","最好玩的航海网游");
        getContentResolver().insert(uri,mContentValues);
        Cursor gameCursor = getContentResolver().query(uri, new String[]{"name", "describe"}, null, null, null);
        while (gameCursor.moveToNext()){
            Game game = new Game(gameCursor.getString(0), gameCursor.getString(1));
            ShowLogUtil.info(game);
        }
    }
}